package com.sc.passbook.mapper;

import com.sc.passbook.constant.Constant;
import com.sc.passbook.vo.FeedBack;
import com.spring4all.spring.boot.starter.hbase.api.RowMapper;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

/**
 * @author sc
 * Created on  2018/9/1
 */
public class FeedBackMapper implements RowMapper<FeedBack> {


    private static byte[] FAMILY_I = Constant.FeedBackTable.FAMILY_I.getBytes();
    private static byte[] USER_ID = Constant.FeedBackTable.USER_ID.getBytes();
    private static byte[] TYPE = Constant.FeedBackTable.TYPE.getBytes();
    private static byte[] TEMPLATE_ID = Constant.FeedBackTable.TEMPLATE_ID.getBytes();
    private static byte[] COMMENT = Constant.FeedBackTable.COMMENT.getBytes();


    @Override
    public FeedBack mapRow(Result result, int i) throws Exception {
        FeedBack feedBack = new FeedBack();
        feedBack.setComment(Bytes.toString(result.getValue(FAMILY_I,COMMENT)));
        feedBack.setUserId(Bytes.toLong(result.getValue(FAMILY_I,USER_ID)));
        feedBack.setType(Bytes.toString(result.getValue(FAMILY_I,TYPE)));
        feedBack.setTemplateId(Bytes.toString(result.getValue(FAMILY_I,TEMPLATE_ID)));
        return feedBack;
    }
}
